package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.xuehua.SnowflakeIdUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GradedAlarmHistory;
import com.ruoyi.system.service.IGradedAlarmHistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分级报警历史Controller
 * 
 * @author ruoyi
 * @date 2024-11-19
 */
@RestController
@RequestMapping("/system/alarmHistory")
public class GradedAlarmHistoryController extends BaseController
{
    @Autowired
    private IGradedAlarmHistoryService gradedAlarmHistoryService;

    /**
     * 查询分级报警历史列表
     */
    @PreAuthorize("@ss.hasPermi('system:alarmHistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(GradedAlarmHistory gradedAlarmHistory)
    {
        startPage();
        List<GradedAlarmHistory> list = gradedAlarmHistoryService.selectGradedAlarmHistoryList(gradedAlarmHistory);
        return getDataTable(list);
    }

    /**
     * 导出分级报警历史列表
     */
    @PreAuthorize("@ss.hasPermi('system:alarmHistory:export')")
    @Log(title = "分级报警历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GradedAlarmHistory gradedAlarmHistory)
    {
        List<GradedAlarmHistory> list = gradedAlarmHistoryService.selectGradedAlarmHistoryList(gradedAlarmHistory);
        ExcelUtil<GradedAlarmHistory> util = new ExcelUtil<GradedAlarmHistory>(GradedAlarmHistory.class);
        util.exportExcel(response, list, "分级报警历史数据");
    }

    /**
     * 获取分级报警历史详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:alarmHistory:query')")
    @GetMapping(value = "/{gradedAlramHistoryId}")
    public AjaxResult getInfo(@PathVariable("gradedAlramHistoryId") String gradedAlramHistoryId)
    {
        return success(gradedAlarmHistoryService.selectGradedAlarmHistoryByGradedAlramHistoryId(gradedAlramHistoryId));
    }

    /**
     * 新增分级报警历史
     */
    @PreAuthorize("@ss.hasPermi('system:alarmHistory:add')")
    @Log(title = "分级报警历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GradedAlarmHistory gradedAlarmHistory)
    {
        return toAjax(gradedAlarmHistoryService.insertGradedAlarmHistory(gradedAlarmHistory));
    }

    /**
     * 修改分级报警历史
     */
    @PreAuthorize("@ss.hasPermi('system:alarmHistory:edit')")
    @Log(title = "分级报警历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GradedAlarmHistory gradedAlarmHistory)
    {
        return toAjax(gradedAlarmHistoryService.updateGradedAlarmHistory(gradedAlarmHistory));
    }

    /**
     * 删除分级报警历史
     */
    @PreAuthorize("@ss.hasPermi('system:alarmHistory:remove')")
    @Log(title = "分级报警历史", businessType = BusinessType.DELETE)
	@DeleteMapping("/{gradedAlramHistoryIds}")
    public AjaxResult remove(@PathVariable String[] gradedAlramHistoryIds)
    {
        return toAjax(gradedAlarmHistoryService.deleteGradedAlarmHistoryByGradedAlramHistoryIds(gradedAlramHistoryIds));
    }
}
